import {USER} from '@/services/api'
import {request, METHOD} from '@/utils/request'


/**
 *
 * @param pageQuery
 * @returns Promise<AxiosResponse>
 */
export async function page(pageQuery) {
    return request(USER.USER_PAGE, METHOD.POST, {
        ...pageQuery
    })
}

/**
 * @returns Promise<AxiosResponse>
 */
export async function list() {
    return request(USER.USER_LIST, METHOD.POST, {})
}

/**
 *
 * @param id
 * @returns Promise<AxiosResponse>
 */
export async function del(id) {
    return request(USER.USER_DELETE + `/${id}`, METHOD.POST, {})
}

/**
 *
 * @param user
 * @returns Promise<AxiosResponse>
 */
export async function save(user) {
    return request(USER.USER_ADD_OR_UPDATE, METHOD.POST, {
        ...user,
    })
}

export const columns = [
    {
        title: '名字',
        dataIndex: 'name',
        align: 'center',
    },
    {
        title: '账号',
        dataIndex: 'username',
        align: 'center',
    },
    {
        title: '性别',
        dataIndex: 'sex',
        align: 'center',
        scopedSlots: {customRender: 'sexIndex'}
    },
    {
        title: '出生日期',
        dataIndex: 'birthday',
        align: 'center',
    },
    {
        title: '电话',
        dataIndex: 'phone',
        align: 'center',
    },
    {
        title: '地址',
        dataIndex: 'address',
        align: 'center',
    },
    {
        title: '角色',
        dataIndex: 'roleNames',
        align: 'center',
        scopedSlots: {customRender: 'roleNamesIndex'}
    },
    {
        title: '操作',
        align: 'center',
        scopedSlots: {customRender: 'action'}
    }
]
